package net.jjjshop.front.service.user;

import com.baomidou.mybatisplus.core.metadata.IPage;
import me.chanjar.weixin.common.bean.WxOAuth2UserInfo;
import net.jjjshop.common.entity.lbt.*;
import net.jjjshop.common.entity.user.User;
import net.jjjshop.framework.common.service.BaseService;
import net.jjjshop.front.param.AppWxParam;
import net.jjjshop.front.param.user.LineUpParam;
import net.jjjshop.front.param.user.PhoneRegisterParam;
import net.jjjshop.front.vo.user.LoginUserTokenVo;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 用户记录表 服务类
 * @author jjjshop
 * @since 2022-07-01
 */
public interface UserService extends BaseService<User> {

    /**
     * 手机号密码登录
     * @param mobile
     * @param password
     * @return
     */
    LoginUserTokenVo login(String mobile, String password);

    /**
     * 微信小程序登录
     * @param appWxParam
     * @return
     */
    LoginUserTokenVo loginWx(AppWxParam appWxParam);

    /**
     * 微信公众号登录
     * @param wxMpUser
     * @return
     */
    LoginUserTokenVo loginMp(WxOAuth2UserInfo wxMpUser, Integer refereeId);

    /**
     * 手机号验证码登录
     * @param mobile
     * @param code
     * @return
     */
    LoginUserTokenVo loginSms(String mobile, String code);
    /**
     * 修改密码
     * @param password
     * @return
     */
    Boolean renew(String mobile, String code, String password);

    /**
     * 退出
     * @param request
     * @throws Exception
     */
    void logout(HttpServletRequest request) throws Exception;


    /**
     * 修改用户信息
     * @param userId
     * @param updateType
     * @param updateValue
     * @return
     */
    Boolean updateInfo(Integer userId, String updateType, String updateValue);

    /**
     * 绑定手机号
     * @param sessionKey
     * @param encryptedData
     * @param iv
     * @return
     */
    String bindMobileByWx(Integer userId, String sessionKey, String encryptedData, String iv);

    /**
     * 获取sessionKey
     * @param code
     * @return
     */
    String getSessionKey(String code);

    /**
     * 累积用户的可用积分
     */
    Boolean setIncPoints(Integer userId, Integer points, String describe, Boolean upgrade);

    //h5注册
    boolean phoneRegister(PhoneRegisterParam phoneRegisterParam);

    /**
     * 我的团队
     */
    TeamBean queryTeam(Integer uid, BigDecimal payMonet);

    /**
     * 查询用户公排记录
     * @return
     */
    IPage<LbLineUp> queryUserUpList(LineUpParam lineUpParam);

    /**
     * 取消公排
     * @param
     * @return
     */
    Integer cancelUp(LbLineUpRequest request);

    /**
     * 我的团队
     */
    UserTeamResponse getUserTeam();

    Map<String,Object> getTeamData();

    /**
     * 设置交易密码
     * @param phone
     * @param smgCode
     * @return
     */
    Boolean setPayPass(String phone,String smgCode,String payPass,String type);

    /**
     * 重置登录密码
     * @param phone
     * @param smgCode
     * @return
     */
    String setLoginPass(String phone,String smgCode,String pass,String type);

    /**
     * 添加/扣减余额
     * @param uid 用户id
     * @param price 金额
     * @param nowMoney 历史金额
     * @param type 类型：add—添加，sub—扣减
     */
    Boolean operationBalance(Integer uid, BigDecimal price, BigDecimal nowMoney, String type);
    Boolean operationCashMoney(Integer uid, BigDecimal price, BigDecimal nowMoney, String type);


    /**
     * 查询公排分类
     * @return
     */
    List<LbLineClass> getLineClass();

    /**
     * 根据手机号查询用户
     * @param phone 用户手机号
     * @return 用户信息
     */
    User getByPhone(String phone);


    /**
     * 查询节点数据
     * @param pid
     * @return
     */
    List<User> getLayer(Integer pid);


    /**
     * 获取A线业绩
     * @param uid
     * @return
     */
    BigDecimal getAline(Integer uid);

    BigDecimal getYjMoney(Integer uid);


}
